const cloud = require('wx-server-sdk')
cloud.init()
exports.main = async (event, context) => {
  var m_path = event.path;
  var m_width = event.width;
  try {
    const result = await cloud.openapi.wxacode.get({
      path: m_path,
      width: m_width
    })
    return {
      buffer: await cloud.uploadFile({
        cloudPath: 'qrcode.jpg',
        fileContent: result.buffer,
      }),
    }
  } catch (err) {
    console.log(err)
    return err
  }
}